extends c
extends qt

snippet class "class template" b
class ${1:Name}
{
private:

public:
    $1() = default;
    $1(const $1& cpy);  // 拷贝构造函数
    $1& operator=(const $1& assign)   // 
    {
        //this->m_a = as.m_a;
	return *this;
    };

    $1(const $1 && cpy);  // 移动构造函数
    $1& operator=($1&& assign); // 移动赋值运算符

    ~$1();

    // 类内声明，类外定义，非成员函数，但可以直接访问类私有变量
    // friend void func($1 & data);  
};
endsnippet

snippet templatef "function template"
template <typename ${1:T}>
void swap($1 &a, $1 &b);
endsnippet

snippet iterator "contains iterator"
${1:array<int, 4>}::iterator ${2:p};
endsnippet

snippet lambda "lambda function template"
[] (${1:param}) -> ${2:return_type} { ${3:code}}
endsnippet

snippet point "智能指针"
std::${1:unique}_ptr<std::${2:type}> ${point_name} {new std::$2 {"example"} };
endsnippet

snippet solution "leetcode cpp solution template" b
#include <iostream>
#include <vector>

using namespace std;

class Solution
{
public:
    ${1:solution method}
};

int main(int argc, char* argv[])
{
    Solution    s;
    // test code
    return 0;
}

endsnippet


snippet timeit "calculate the time of the function spent"
// #include <chrono>
// using namespace std::chrono;
// timeit("with reserve: ", with_reserve);
template<typename F>
void timeit(string prefix, F&& f) 
{
    auto st = steady_clock::now();
    f();
    auto ed = steady_clock::now();
    auto diff = duration_cast<duration<double>>(ed - st);
    cout << prefix << diff.count() << endl;
}
endsnippet


snippet benchmark "google benchmark template" b
#include <benchmark/benchmark.h>

void ${1:function_for_benchmark}(void);

static void BM_$1(benchmark::State& state)
{
    for(auto _ : state)
        $1();
}
BENCHMARK(BM_$1);

BENCHMARK_MAIN();
endsnippet
